﻿using System.Linq;
using System.Text.RegularExpressions;
using TechTalk.SpecFlow;

namespace Scrabble.Model.Tests.Support
{
    [Binding]
    public class StringArrayConverter
    {
        [StepArgumentTransformation]
        public string[] Transform(string text)
        {
            // Given a string holding a comma-delimited list of quoted text, extract the text elements (unquoted) 
            // and return them as a string array.

            return (text.Split(new[] { ',' }).Select(item => Regex.Match(item, @"\s*'(?<item>.+?)'").Groups["item"].Value)).ToArray();
        }
    }
}
